package com.hins.demo.ability;

import com.hins.demo.model.transfer.entity.Account;
import com.hins.demo.model.transfer.valueobject.ExchangeRate;
import com.hins.demo.model.transfer.valueobject.Money;
import org.springframework.stereotype.Service;

@Service
public class AccountTransferServiceImpl implements AccountTransferService {

    @Override
    public void transfer(Account sourceAccount, Account targetAccount, Money targetMoney, ExchangeRate exchangeRate) {
        Money sourceMoney = exchangeRate.exchange(targetMoney);
        sourceAccount.deposit(sourceMoney);
        targetAccount.withdraw(targetMoney);
    }
}